package com.efast.cafe.portal.controller.common;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.efast.cafe.framework.bean.ResultBean;
import com.efast.cafe.framework.enums.ResultStatus;
import com.efast.cafe.portal.entity.company.PortalFieldLog;
import com.efast.cafe.portal.service.company.PortalFieldLogService;

@Controller
public class CollectionFeLogController {
	
	//private static ExtLogger log = ExtLoggerCommon.getLogger(CollectionFeLogController.class);

	@Autowired
	private PortalFieldLogService portalFieldLogService;
	
	/**
	 * 采集前端错误日志
	 * @param map
	 * @return
	 */
	@RequestMapping(value = "/frame_center/common/fe_logs")
	public @ResponseBody ResultBean saveFeLogs(
			@RequestBody Map<String,Object> map){
		ResultBean res = new ResultBean(true, "");
		try{
			//log.dbLog(Level.ERROR, map, "FE_LOGS");
		}catch(Exception e){
			res.setSuccess(false);
			res.setErrorCode(ResultStatus.SYS_ERROR.getCode());
			res.setMessage(e.getMessage());
		}
		return res;
	}
	
	@RequestMapping(value = "/frame_center/common/fe_field_logs")
	public @ResponseBody ResultBean saveFeFieldLogs(
			@RequestBody List<PortalFieldLog> logs){
		ResultBean res = new ResultBean(true, "");
		try{
			portalFieldLogService.insertLog(logs);
		}catch(Exception e){
			res.setSuccess(false);
			res.setErrorCode(ResultStatus.SYS_ERROR.getCode());
			res.setMessage(e.getMessage());
		}
		return res;
	}
}
